package com.bootdo.merchant.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.bootdo.common.utils.StringUtils;
import com.bootdo.merchant.dao.MerchantDao;
import com.bootdo.merchant.domain.MerchantDO;

/**
 * @Desc 商户编号重复验证
 * @date 2019/11/15
 *
 */
@Component
public class IdentUtils {

    @Autowired
    private MerchantDao merchantMapper;

    public String getIdentStr(int size){
        String ident = StringUtils.getUUIDStr(size);
        //验证商户编号是否重复
        MerchantDO merchant = merchantMapper.getByIdent(ident);
        if (merchant != null){
            getIdentStr(size);
        }
        return ident;
    }
}
